package hello
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.log4j.{Level, Logger}
object flatMap {
  def main(args: Array[String]): Unit = {
        val conf = new SparkConf().setMaster("local[2]").setAppName("RDDFlatMap")
        Logger.getLogger("org.apache.spark").setLevel(Level.OFF)
        val sc = new SparkContext(conf)
        transformationOps3(sc)
        sc.stop()
    }
  def transformationOps3(sc:SparkContext): Unit = {
        val list = List("hello you", "hello he", "hello me")
        val listRDD = sc.parallelize(list)
        val wordsRDD = listRDD.flatMap(line => line.split(" "))//对集合中每个元素进行操作然后再扁平化。
        wordsRDD.foreach(println)
    }
}